﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; 
using System.IO;
using System.Web.Script.Serialization;
using System.Reflection;
using System.Xml;
using System.Xml.Serialization;
using System.Xml.Linq;
using Discio;

namespace Testing
{
    class Program
    {

        static void Main(string[] args)
        {

            SiteSources.Source["main"] = new Source
            {
                DataFolder = @"C:\Temp\Data\"
            };


            var man = new Manager<User>("users");

            var count = man.Count();
            
            //Load all users
            for (int i = 0; i < 15000; i++)
            {

                count++;

                man.Insert(new User
                {
                    FirstName = "Walter " + count,
                    LastName = "Soto " + count,
                    DOB = DateTime.Today
                });
            }

            man.Commit();



            Console.WriteLine();
            Console.WriteLine("Press any key.");
            Console.ReadLine();

        } 

    }

 
    public class User : IDiscio
    {
        /// <summary>
        /// This property is required by the IDiscio interface.
        /// </summary>
        public string ID { set; get; }

        public string FirstName { set; get; }
        public string LastName { set; get; }
        public int Age
        {
            get
            {
                int age = DateTime.Today.Year - DOB.Year;
                if (DOB > DateTime.Today.AddYears(-age))
                {
                    age--;
                }
                return age;
            }
        }
        public DateTime DOB { set; get; }


    }

 
     
}
